const string or_ed_keywords = string( "ALL|ANALYSE|ANALYZE|AND|ANY|ARRAY|AS|ASC"
		"|ASYMMETRIC|AUTHORIZATION|BOTH|BINARY|CASE|CAST|CHECK|COLLATE|COLUMN"
		"|CONSTRAINT|CREATE|CURRENT_CATALOG|CURRENT_DATE|CURRENT_ROLE"
		"|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|COLLATION|CONCURRENTLY"
		"|CROSS|CURRENT_SCHEMA|DEFAULT|DEFERRABLE|DESC|DISTINCT|DO|ELSE|END"
		"|EXCEPT|FALSE|FETCH|FOR|FOREIGN|FROM|FREEZE|FULL|GRANT|GROUP"
		"|GR#OUP#BY|HAVING|IN|INITIALLY|INTERSECT|INTO|ILIKE|INNER|IS"
		"|ISNULL|JOIN|J#O#I#N|LEADING|LIMIT|LOCALTIME|LOCALTIMESTAMP|LEFT"
		"|LIKE|NOT|NULL|NATURAL|NOTNULL|OFFSET|ON|ONLY|OR|ORDER|OR#DER#BY"
		"|OUTER|OVER|OVERLAPS|PLACING|PRIMARY|PA#RTI#T#ION#BY|REFERENCES"
		"|RETURNING|RIGHT|SELECT|SESSION_USER|SOME|SYMMETRIC|SIMILAR"
		/* ILLEGAL (AT LEAST FOR POSTGRESQL) USE OF "TABLE" AS A FUNCTION
		 * NAME IN THE SAMPLE LOG ENCOUNTERED. OMITTED FROM THE "LIST"... */
		"|THEN|TO|TRAILING|TRUE|UNION|UNIQUE|USER|USING|VARIADIC|VERBOSE|"
		"WHEN|WHERE|WINDOW|WITH" );

static const string or_ed_select_query_keywords = "(SELECT|FROM|WHERE|(GR#OUP#BY)|HAVING|WINDOW"
		"|UNION|INTERSECT|EXCEPT|(OR#DER#BY)|LIMIT|OFFSET|FETCH|FOR|J#O#I#N|J#O#I#N#ON)"; // WITH + #P#B#

// Returns "TRUE" if the string supplied
// matches a keyword (loosely) without any
// regard to case, else returns "FALSE".
bool is_not_keyword( const string& word ){

	static const vector<string> keywords{
		"ALL", "ANALYSE", "ANALYZE", "AND", "ANY", "ARRAY",
			"AS", "ASC", "ASYMMETRIC", "AUTHORIZATION",
		"BOTH", "BINARY",
		"CASE", "CAST", "CHECK", "COLLATE", "COLUMN", "CONSTRAINT", "CREATE",
			"CURRENT_CATALOG", "CURRENT_DATE", "CURRENT_ROLE", "CURRENT_TIME",
			"CURRENT_TIMESTAMP", "CURRENT_USER", "COLLATION", "CONCURRENTLY",
			"CROSS", "CURRENT_SCHEMA",
		"DEFAULT", "DEFERRABLE", "DESC", "DISTINCT", "DO",
		"ELSE", "END", "EXCEPT",
		"FALSE", "FETCH", "FOR", "FOREIGN", "FROM", "FREEZE", "FULL",
		"GRANT", "GROUP", "GR#OUP#BY",
		"HAVING",
		"IN", "INITIALLY", "INTERSECT", "INTO", "ILIKE", "INNER",
			"IS", "ISNULL",
		"JOIN", "J#O#I#N",
		"LEADING", "LIMIT", "LOCALTIME", "LOCALTIMESTAMP", "LEFT", "LIKE",
		"NOT", "NULL", "NATURAL", "NOTNULL",
		"OFFSET", "ON", "ONLY", "OR", "ORDER", "OR#DER#BY", "OUTER", "OVER",
			"OVERLAPS",
		"PLACING", "PRIMARY", "PA#RTI#T#ION#BY",
		"REFERENCES", "RETURNING", "RIGHT",
		"SELECT", "SESSION_USER", "SOME", "SYMMETRIC", "SIMILAR",
		"TABLE", "THEN", "TO", "TRAILING", "TRUE",
		"UNION", "UNIQUE", "USER", "USING",
		"VARIADIC", "VERBOSE",
		"WHEN", "WHERE", "WINDOW", "WITH",
		// Included despite these not being
		// standard(?) PostgreSQL keywords.
		"BETWEEN", "INSERT"
	};

	string uppercase = to_upper_copy( word );
	if( find( keywords.begin(), keywords.end(),
			uppercase ) != keywords.end() )
		return false;

	return true;

}
